package com.hit.server.biz.controller;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hit.common.core.util.HitConvertUtils;
import com.hit.common.core.util.R;
import com.hit.common.log.annotation.SysLog;
import com.hit.server.api.dto.CheckTaskTicketsQueryDTO;
import com.hit.server.api.vo.CheckTaskTicketsVO;
import com.hit.server.api.service.CheckTaskTicketsService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * 检测任务工单
 *
 * @author kehanjiang
 * @date 2025-04-18 15:49:27
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/checkTaskTickets" )
@Tag(description = "checkTaskTickets" , name = "检测任务工单管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CheckTaskTicketsController {

    private final  CheckTaskTicketsService checkTaskTicketsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param dto 检测任务工单
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @GetMapping("/page" )
    public R<Page<CheckTaskTicketsVO>> getCheckTaskTicketsPage(@ParameterObject Page page, @ParameterObject CheckTaskTicketsQueryDTO dto) {
	    dto = HitConvertUtils.emptyToNull(dto);
        return R.ok(checkTaskTicketsService.getCheckTaskTicketsPage(page, dto));
    }


    /**
     * 通过id查询检测任务工单
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/{id}" )
    public R<CheckTaskTicketsVO> getById(@PathVariable("id" ) Long id) {
        return R.ok(checkTaskTicketsService.getCheckTaskTicketsById(id));
    }

    /**
     * 通过id删除检测任务工单
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除检测任务工单" , description = "通过id删除检测任务工单" )
    @SysLog("通过id删除检测任务工单" )
    @DeleteMapping
    public R<Boolean> removeById(@RequestBody Long[] ids) {
        return R.ok(checkTaskTicketsService.removeCheckTaskTicketsBatchByIds(CollUtil.toList(ids)));
    }


}